<template>
	<view class="content fofa">
		<tabnav title="我持有的企业印章" :col="back"></tabnav>
		<view style="height: 40rpx;"></view>
		<scroll-view :style="'height: calc(100vh - 40rpx - 90rpx - '+tops+'px);'" @refresherrefresh="onPulling" :refresher-triggered="triggered"
			scroll-y="true" class="scroll-Y" @scrolltolower="lower" :refresher-enabled="true">
			<view class="wid100" v-if="list.length == 0">
				<view class="wid100" style="height: 220rpx;"></view>
				<view class="wid100 textCen">
					<image src="https://www.sign.run/applet/static/wenjian/wushuju.png" style="width: 306rpx;height: 200rpx;"></image>
					<view class="mar-top30 foSi25" style="color: #858585;">请联系企业印章管理员或企业超管进行印章授权</view>
				</view>
			</view>
			<view class="wid100" v-if="list.length != 0">
				<block v-for="(item,index) in list" :key="index">
					<view class="wid87 mar borRad20 bacFFF mar-bott30">
						<view class="wid100 dis disAl disJuC poRel" style="height: 223rpx;">
							<view class="poAbs dis disAl disJuC coFFF foSi20" :style="{'background-color':back}"
							style="top: 40rpx;left: 0;border-top-right-radius: 40rpx;border-bottom-right-radius: 40rpx;padding: 10rpx 20rpx;">
							{{item.sealStatus == 'CHECKING'?'审核中':
							item.sealStatus == 'SUCCESS'?'已启用':
							item.sealStatus == 'FAIL'?'审核拒绝':
							item.sealStatus == 'CHECKING-SADM'?'待超管审核':
							item.sealStatus == 'DISABLE'?'已停用':
							item.sealStatus == 'STOPPED'?'已终止':''}}</view>
							<image :src="item.url" style="width: 180rpx;height: 180rpx;"></image>
						</view>
						<view class="xia"></view>
						<view class="hei80 wid90 mar dis disAl foSi25">
						{{item.sealType == 'OFFICIAL'?'企业公章':
						item.sealType == 'CONTRACT'?'合同专用章':
						item.sealType == 'LEGAL_PERSON_SEAL'?'法人章':''}}</view>
					</view>
				</block>
			</view>
			<view style="height: 40rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	import tabnav from "../common/tabnav/tabnav.vue"
	export default {
		components: {
			tabnav,
		},
		data() {
			return {
				back: uni.getStorageSync('back'),
				last_page: 0,
				page: 1,
				triggered: false,
				_freshing: false,
				list: [],
				tops: 0
			}
		},
		onLoad() {
			this.appletSeal()
		},
		created() {
			var that = this
			uni.getSystemInfo({
				success: (e) => {
					console.log(e)
					that.tops = e.statusBarHeight
				}
			})
		},
		methods: {
			appletSeal(){
				var that = this
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: that.global.url+'api/qianyu_dzq/applet_corporate_seal',
					method: 'POST',
					header:{'site-id':that.global.site_id,'token': uni.getStorageSync('inuse_userinfo_token')},
					data: {
						page: that.page
					},
					success(res) {
					    let result = res.data
						console.log(result);
					    if(result.code == 1){
							if(that.page == 0){
								that.list = result.data.seals
							}else{
								that.list = that.list.concat(result.data.seals)
							}
							that.last_page = result.data.totalCount
					    }else{
					        uni.showToast({
					            title: result.msg,
					            icon:'none',
								duration: 2000
					        })
					    }
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			tiaozhuan(url){
				uni.redirectTo({
					url: url
				});
			},
			onPulling(e) {
				var that = this
				if (that._freshing) return;
				that._freshing = true;
				that.triggered = true
				console.log("onpulling", e);
				setTimeout(() => {
					that.triggered = false;
					that._freshing = false;
					that.page = 0
					that.appletSeal()
				}, 1000)
			},
			lower(e) {
				if(this.last_page != this.page){
					this.page++
					this.appletSeal()
				}
			},
		}
	}
</script>

<style>
	.content {
		height: 100vh;
		background-color: #F4F3F3;
	}
	.foSi28{
		font-size: 28rpx;
	}
	.xia{
		height: 1rpx;
		background: #E5E5E5;
	}
</style>
